package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zabz extends zbz {
   ArrayList a;

   zabz() {
      this.c(4198);
   }

   void a(FillFormat var1) {
      switch(var1.getType()) {
      case 2:
         this.d(var1);
         break;
      case 3:
         if (var1.getGradientFill().getGradientStops().getCount() != 0) {
            this.c(var1);
         }
         break;
      case 4:
         if (var1.getTexture() == 24) {
            this.a(var1.getTextureFill().b());
         } else {
            this.a(var1.getTexture());
         }
         break;
      case 5:
         this.b(var1);
      }

   }

   private void a(byte[] var1) {
      byte[] var2 = this.g();
      int var3 = this.a() + var1.length + var2.length;
      if (var3 > 8224) {
         this.a((short)8224);
      } else {
         this.a((short)var3);
      }

      this.c = new byte[this.d()];
      int var4 = this.a();
      System.arraycopy(this.c(), 0, this.c, 0, this.a());
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3 - 8 - var2.length), 0, this.c, 4, 4);
      this.c[10] = 3;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.length), 0, this.c, this.b(), 4);
      if (var3 <= 8224) {
         System.arraycopy(var1, 0, this.c, var4, var1.length);
         System.arraycopy(var2, 0, this.c, var4 + var1.length, var2.length);
      } else {
         this.a = new ArrayList();
         int var5 = 8224 - var4;
         if (var5 > var1.length) {
            System.arraycopy(var1, 0, this.c, var4, var1.length);
            System.arraycopy(var2, 0, this.c, var1.length, var5 - var1.length);
         } else {
            System.arraycopy(var1, 0, this.c, var4, 8224 - var4);
         }

         Object var6 = null;
         boolean var7 = false;

         while(var5 < var1.length + var2.length) {
            int var10 = var1.length + var2.length - var5;
            zmo var8 = new zmo();
            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var8);
            byte[] var9;
            if (var10 <= 8224) {
               var9 = new byte[var10];
               if (var10 <= var2.length) {
                  System.arraycopy(var2, var2.length - var10, var9, 0, var10);
               } else {
                  System.arraycopy(var1, var5, var9, 0, var10 - var2.length);
                  System.arraycopy(var2, 0, var9, var10 - var2.length, var2.length);
               }

               var8.b(var9);
               var5 = var1.length + var2.length;
            } else {
               var9 = new byte[8224];
               if (var5 + 8224 > var1.length) {
                  System.arraycopy(var1, var5, var9, 0, var1.length - var5);
                  System.arraycopy(var2, 0, var9, var1.length - var5, 8224 + var5 - var1.length);
               } else {
                  System.arraycopy(var1, var5, var9, 0, 8224);
               }

               var8.b(var9);
               var5 += 8224;
            }
         }
      }

   }

   void a(int var1) {
      byte[] var2 = zvj.a(var1);
      if (var2 != null) {
         this.a((short)(var2.length + this.a()));
         this.c = new byte[this.d()];
         System.arraycopy(this.c(), 0, this.c, 0, this.a());
         System.arraycopy(var2, 0, this.c, this.a(), var2.length);
         System.arraycopy(com.aspose.cells.b.a.zc.a((short)(this.d() - 8)), 0, this.c, 4, 2);
         this.c[10] = 2;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length), 0, this.c, this.b(), 4);
      }
   }

   void b(FillFormat var1) {
      byte[] var2 = MsoFillFormatHelper.f(var1.getPattern());
      if (var2 != null) {
         this.a((short)(var2.length + this.a()));
         this.c = new byte[this.d()];
         System.arraycopy(this.c(), 0, this.c, 0, this.a());
         System.arraycopy(var2, 0, this.c, this.a(), var2.length);
         System.arraycopy(com.aspose.cells.b.a.zc.a((short)(this.d() - 8)), 0, this.c, 4, 2);
         this.c[10] = 1;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length), 0, this.c, this.b(), 4);
         this.a(16, var1.getPatternFill().getForegroundColor());
         this.a(28, var1.getPatternFill().getBackgroundColor());
      }
   }

   void a(Area var1) {
      this.a((short)this.a());
      this.c = new byte[this.d()];
      System.arraycopy(this.c(), 0, this.c, 0, this.a());
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)(this.d() - 8)), 0, this.c, 4, 2);
      this.a(16, var1.getForegroundColor());
      this.a(22, (float)var1.getTransparency());
      this.a(28, var1.getBackgroundColor());
   }

   private void d(FillFormat var1) {
      this.a((short)this.a());
      this.c = new byte[this.d()];
      System.arraycopy(this.c(), 0, this.c, 0, this.a());
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)(this.d() - 8)), 0, this.c, 4, 2);
      this.a(16, var1.getSolidFill().getColor());
      this.a(22, (float)var1.getSolidFill().getTransparency());
      this.a(28, Color.getEmpty());
   }

   private void a(int var1, Color var2) {
      this.c[var1] = com.aspose.cells.a.c.zh.b(var2);
      this.c[var1 + 1] = com.aspose.cells.a.c.zh.c(var2);
      this.c[var1 + 2] = com.aspose.cells.a.c.zh.d(var2);
   }

   private void a(int var1, float var2) {
      int var3 = zash.a(1.0F - var2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, this.c, var1, 4);
   }

   void c(FillFormat var1) {
      zanu var2 = new zanu(var1.getGradientFill());
      byte[] var3 = var2.b;
      if (var3 != null) {
         this.a((short)(this.a() + var3.length));
         this.c = new byte[this.d()];
         System.arraycopy(var3, 0, this.c, this.a(), var3.length);
      } else {
         this.b(188);
         this.c = new byte[this.d()];
      }

      this.c[0] = -29;
      this.c[1] = 1;
      this.c[2] = 11;
      this.c[3] = -16;
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)(this.d() - 8)), 0, this.c, 4, 2);
      this.c[8] = -128;
      this.c[9] = 1;
      switch(var2.a()) {
      case 5:
         this.c[10] = 5;
         break;
      case 6:
         this.c[10] = 6;
         break;
      default:
         this.c[10] = 7;
      }

      this.a(this.c, 14, 385, var2.e(), var1.a);
      this.a(this.c, 26, 387, var2.f(), var1.a);
      this.c[38] = -123;
      this.c[39] = 1;
      this.c[40] = -12;
      this.c[43] = 16;
      this.c[44] = -122;
      this.c[45] = -63;
      this.c[50] = -121;
      this.c[51] = -63;
      this.c[56] = -120;
      this.c[57] = 1;
      this.c[62] = -119;
      this.c[63] = 1;
      this.c[68] = -118;
      this.c[69] = 1;
      this.c[74] = -117;
      this.c[75] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a((float)var2.c())), 0, this.c, 76, 4);
      this.c[80] = -116;
      this.c[81] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2.d()), 0, this.c, 82, 2);
      double[] var4 = var2.b();
      this.c[86] = -115;
      this.c[87] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a((float)var4[0])), 0, this.c, 88, 4);
      this.c[92] = -114;
      this.c[93] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a((float)var4[1])), 0, this.c, 94, 4);
      this.c[98] = -113;
      this.c[99] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a((float)var4[2])), 0, this.c, 100, 4);
      this.c[104] = -112;
      this.c[105] = 1;
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a((float)var4[3])), 0, this.c, 106, 4);
      this.c[110] = -111;
      this.c[111] = 1;
      this.c[116] = -110;
      this.c[117] = 1;
      this.c[122] = -109;
      this.c[123] = 1;
      this.c[128] = -108;
      this.c[129] = 1;
      this.c[134] = -107;
      this.c[135] = 1;
      this.c[140] = -106;
      this.c[141] = 1;
      this.c[146] = -105;
      this.c[147] = -63;
      if (var3 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var3.length), 0, this.c, 148, 4);
      }

      this.c[152] = -104;
      this.c[153] = 1;
      this.c[158] = -103;
      this.c[159] = 1;
      this.c[164] = -102;
      this.c[165] = 1;
      this.c[170] = -101;
      this.c[171] = 1;
      this.c[176] = -100;
      this.c[177] = 1;
      this.c[178] = 3;
      this.c[181] = 64;
      this.c[182] = -65;
      this.c[183] = 1;
      this.c[184] = 28;
      this.c[186] = 31;
   }

   private void a(byte[] var1, int var2, int var3, GradientStop var4, Workbook var5) {
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, var1, var2, 2);
      this.a(var2 + 2, var4.a.b(var5));
      var2 += 6;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3 + 1), 0, var1, var2, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(zash.a(1.0F - (float)var4.getTransparency())), 0, this.c, var2 + 2, 4);
      var2 += 6;
   }

   int a() {
      return 188;
   }

   int b() {
      return 46;
   }

   private byte[] c() {
      return new byte[]{-29, 1, 11, -16, -76, 0, 0, 0, -128, 1, 0, 0, 0, 0, -127, 1, 0, 0, 0, 0, -126, 1, 0, 0, 1, 0, -125, 1, 0, 0, 0, 0, -124, 1, 0, 0, 1, 0, -123, 1, -12, 0, 0, 16, -122, -63, 0, 0, 0, 0, -121, -63, 0, 0, 0, 0, -120, 1, 0, 0, 0, 0, -119, 1, 0, 0, 0, 0, -118, 1, 0, 0, 0, 0, -117, 1, 0, 0, 0, 0, -116, 1, 100, 0, 0, 0, -115, 1, 0, 0, 0, 0, -114, 1, 0, 0, 0, 0, -113, 1, 0, 0, 0, 0, -112, 1, 0, 0, 0, 0, -111, 1, 0, 0, 0, 0, -110, 1, 0, 0, 0, 0, -109, 1, 0, 0, 0, 0, -108, 1, 0, 0, 0, 0, -107, 1, 0, 0, 0, 0, -106, 1, 0, 0, 0, 0, -105, -63, 0, 0, 0, 0, -104, 1, 0, 0, 0, 0, -103, 1, 0, 0, 0, 0, -102, 1, 0, 0, 0, 0, -101, 1, 0, 0, 0, 0, -100, 1, 11, 0, 0, 64, -65, 1, 28, 0, 31, 0};
   }

   private byte[] g() {
      return new byte[]{3, 0, 34, -15, 0, 0, 0, 0};
   }

   void a(zqa var1) throws Exception {
      if (this.c != null) {
         var1.a(this.f());
         var1.a(this.d());
         var1.a(this.c);
         if (this.a != null) {
            Iterator var2 = this.a.iterator();

            while(var2.hasNext()) {
               zmo var3 = (zmo)var2.next();
               var3.a(var1);
            }
         }

      }
   }
}
